Skip to content

【训练营】基于 CTest + gtest 的测试体系搭建与工程化集成#120

Open
luoyueyuguang wants to merge 2 commits intoInfiniTensor:masterfrom
luoyueyuguang:master
Open

【训练营】基于 CTest + gtest 的测试体系搭建与工程化集成#120
luoyueyuguang wants to merge 2 commits intoInfiniTensor:masterfrom
luoyueyuguang:master

Conversation

@luoyueyuguang
Copy link

No description provided.

@chen2021673
Copy link
Contributor

chen2021673 commented Mar 18, 2026

1.请不要用 merge 操作,统一使用 rebase 同步最新修改;
2.请补充 PR description;
3.请解决目前 pr 与 master 分支的冲突。

CMakeLists.txt Outdated
add_subdirectory(third_party/glog)
add_compile_definitions(GLOG_USE_GLOG_EXPORT=1)
include_directories(${glog_SOURCE_DIR}/src)
include_directories(${glog_BINARY_DIR}/glog)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是否可以删除

CMakeLists.txt Outdated
file(GLOB_RECURSE SRC ${PROJECT_SOURCE_DIR}/infini_train/src/*.cc)
list(FILTER SRC EXCLUDE REGEX ".*kernels/cpu/.*")
list(FILTER SRC EXCLUDE REGEX ".*runtime/cuda/.*")
list(FILTER SRC EXCLUDE REGEX ".*ccl/cuda/.*")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的逻辑应该是

if(NOT USE_CUDA)
  list(FILTER SRC EXCLUDE REGEX ".*runtime/cuda/.*")
  list(FILTER SRC EXCLUDE REGEX ".*ccl/cuda/.*")
endif()

否则会出现编译错误

@@ -0,0 +1,161 @@
# Autograd tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这版的风险是新增测试的接入成本和漏配风险都比较高。新增一个普通 autograd CPU 测试,至少要手动写:

add_autograd_test(...)
add_test(...)
set_tests_properties(... LABELS ...)

建议简化。例如把功能整合到一个函数里,新增测试只调用一次;或者考虑使用gtest_discover_tests,不用再手工写 add_test() 和 set_tests_properties()

@luoyueyuguang luoyueyuguang reopened this Mar 25, 2026
- Add infini_train_add_test CMake macro for simplified test registration
- Integrate gtest_discover_tests for automatic test case discovery
- Refactor all test directories to use unified macro (autograd, optimizer, hook, slow, lora)
- Reduce test CMakeLists.txt code by 68%
- Add LoRA tests (12 test cases)
- Delete TEST_REPORT.md
- Test labels: cpu/cuda/distributed/slow for flexible test execution
- Add shared test_macros.cmake in tests/common/

BREAKING CHANGE: Test registration now uses macro instead of manual add_test()

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@luoyueyuguang
Copy link
Author

修改了CMakeLists.txt,添加了infini_train_add_test宏,可使用以下方式注册tests

infini_train_add_test(
  test_my_feature
  SOURCES test_my_feature.cc
  LABELS cpu
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants